package core.report.yearReport.bean;

import org.springframework.jdbc.support.rowset.SqlRowSet;

import core.report.yearReport.util.ExportExcelUtil;

public class Productyears extends BaseExcelReportDataBean {
	private String name;

	private String itemno;
	private double L_pieces_price;
	private double N_pieces_price;
	private double C_pieces_price;
	private double L_amount;
	private double N_amount;
	private double C_amount;
	private double per_L_amount;
	private double per_N_amount;
	private double per_C_amount;
	private double L_gross_revenue;
	private double N_gross_revenue;
	private double C_gross_revenue;
	private double L_inventory_cost;
	private double N_inventory_cost;
	private double C_inventory_cost;
	
	
	public Productyears() {
	}

	public Productyears(SqlRowSet rs) {
		this.itemno = rs.getString("itemno");
		this.L_pieces_price = rs.getDouble("L_pieces_price");
		this.N_pieces_price = rs.getDouble("N_pieces_price");
		this.C_pieces_price = rs.getDouble("C_pieces_price");
		this.L_amount = rs.getDouble("L_amount");
		this.N_amount = rs.getDouble("N_amount");
		this.C_amount = rs.getDouble("C_amount");
		this.per_L_amount = rs.getDouble("per_L_amount");
		this.per_N_amount = rs.getDouble("per_N_amount");
		this.per_C_amount = rs.getDouble("per_C_amount");
		this.L_gross_revenue = rs.getDouble("L_gross_revenue");
		this.N_gross_revenue = rs.getDouble("N_gross_revenue");
		this.C_gross_revenue = rs.getDouble("C_gross_revenue");
		this.L_inventory_cost = rs.getDouble("L_inventory_cost");
		this.N_inventory_cost = rs.getDouble("N_inventory_cost");
		this.C_inventory_cost = rs.getDouble("C_inventory_cost");
		
		this.name = this.itemno;
	}

	public void addProperties(Productyears data) {
		this.setL_pieces_price(this.getL_pieces_price()+data.getL_pieces_price());
		this.setN_pieces_price(this.getN_pieces_price()+data.getN_pieces_price());
		this.setC_pieces_price(this.getC_pieces_price()+data.getC_pieces_price());
		this.setL_amount(this.getL_amount()+data.getL_amount());
		this.setN_amount(this.getN_amount()+data.getN_amount());
		this.setC_amount(this.getC_amount()+data.getC_amount());
		this.setPer_L_amount(this.getPer_L_amount()+data.getPer_L_amount());
		this.setPer_N_amount(this.getPer_N_amount()+data.getPer_N_amount());
		this.setPer_C_amount(this.getPer_C_amount()+data.getPer_C_amount());
		this.setL_gross_revenue(this.getL_gross_revenue()+data.getL_gross_revenue());
		this.setN_gross_revenue(this.getN_gross_revenue()+data.getN_gross_revenue());
		this.setC_gross_revenue(this.getC_gross_revenue()+data.getC_gross_revenue());
		this.setL_inventory_cost(this.getL_inventory_cost()+data.getL_inventory_cost());
		this.setN_inventory_cost(this.getN_inventory_cost()+data.getN_inventory_cost());
		this.setC_inventory_cost(this.getC_inventory_cost()+data.getC_inventory_cost());
	}

	public void subtract(int size) {
		if (size != 0) {
			this.setC_pieces_price(this.getC_pieces_price()/size);
			this.setC_amount(this.getC_amount()/size);
			this.setPer_L_amount(this.getPer_L_amount()/size);
			this.setPer_N_amount(this.getPer_N_amount()/size);
			this.setPer_C_amount(this.getPer_C_amount()/size);
			this.setL_gross_revenue(this.getL_gross_revenue()/size);
			this.setN_gross_revenue(this.getN_gross_revenue()/size);
			this.setC_gross_revenue(this.getC_gross_revenue()/size);
			this.setC_inventory_cost(this.getC_inventory_cost()/size);
		} else {
			this.setC_pieces_price(0);
			this.setC_amount(0);
			this.setPer_L_amount(0);
			this.setPer_N_amount(0);
			this.setPer_C_amount(0);
			this.setL_gross_revenue(0);
			this.setN_gross_revenue(0);
			this.setC_gross_revenue(0);
			this.setC_inventory_cost(0);
		}
	}

	@Override
	public int getFormatTypeByIndex(int index) {
		switch (index) {
		case 0:
			return ExportExcelUtil.TEXT_TYPE;
		case 1:
			return ExportExcelUtil.DECIMAL_TYPE;
		case 2:
			return ExportExcelUtil.DECIMAL_TYPE;
		case 3:
			return ExportExcelUtil.PERCENT_TYPE;
		case 4:
			return ExportExcelUtil.DECIMAL_TYPE;
		case 5:
			return ExportExcelUtil.DECIMAL_TYPE;
		case 6:
			return ExportExcelUtil.PERCENT_TYPE;
		case 7:
			return ExportExcelUtil.PERCENT_TYPE;
		case 8:
			return ExportExcelUtil.PERCENT_TYPE;
		case 9:
			return ExportExcelUtil.PERCENT_TYPE;
		case 10:
			return ExportExcelUtil.PERCENT_TYPE;
		case 11:
			return ExportExcelUtil.PERCENT_TYPE;
		case 12:
			return ExportExcelUtil.PERCENT_TYPE;
		case 13:
			return ExportExcelUtil.DECIMAL_TYPE;
		case 14:
			return ExportExcelUtil.DECIMAL_TYPE;
		case 15:
			return ExportExcelUtil.PERCENT_TYPE;
		default:
			return ExportExcelUtil.TEXT_TYPE;
		}
	}

	@Override
	public String getValueByIndex(int index) {
		String value = "";
		switch (index) {
		case 0:
			value = this.getName();
			break;
		case 1:
			value = this.getL_pieces_price() + "";
			break;
		case 2:
			value = this.getN_pieces_price() + "";
			break;
		case 3:
			value = this.getC_pieces_price() + "";
			break;
		case 4:
			value = this.getL_amount() + "";
			break;
		case 5:
			value = this.getN_amount() + "";
			break;
		case 6:
			value = this.getC_amount()+ "";
			break;
		case 7:
			value = this.getPer_L_amount() + "";
			break;
		case 8:
			value = this.getPer_N_amount() + "";
			break;
		case 9:
			value = this.getPer_C_amount() + "";
			break;
		case 10:
			value = this.getL_gross_revenue()+ "";
			break;
		case 11:
			value = this.getN_gross_revenue()+ "";
			break;
		case 12:
			value = this.getC_gross_revenue()+ "";
			break;
		case 13:
			value = this.getL_inventory_cost()+ "";
			break;
		case 14:
			value = this.getN_inventory_cost()+ "";
			break;
		case 15:
			value = this.getC_inventory_cost()+ "";
			break;
		}
		return value;
	}

	public String getName() {
		return name;
	}

	public void setName(String name) {
		this.name = name;
	}

	public String getItemno() {
		return itemno;
	}

	public void setItemno(String itemno) {
		this.itemno = itemno;
	}

	public double getL_pieces_price() {
		return L_pieces_price;
	}

	public void setL_pieces_price(double l_pieces_price) {
		L_pieces_price = l_pieces_price;
	}

	public double getN_pieces_price() {
		return N_pieces_price;
	}

	public void setN_pieces_price(double n_pieces_price) {
		N_pieces_price = n_pieces_price;
	}

	public double getC_pieces_price() {
		return C_pieces_price;
	}

	public void setC_pieces_price(double c_pieces_price) {
		C_pieces_price = c_pieces_price;
	}

	public double getL_amount() {
		return L_amount;
	}

	public void setL_amount(double l_amount) {
		L_amount = l_amount;
	}

	public double getN_amount() {
		return N_amount;
	}

	public void setN_amount(double n_amount) {
		N_amount = n_amount;
	}

	public double getC_amount() {
		return C_amount;
	}

	public void setC_amount(double c_amount) {
		C_amount = c_amount;
	}

	public double getL_gross_revenue() {
		return L_gross_revenue;
	}

	public void setL_gross_revenue(double l_gross_revenue) {
		L_gross_revenue = l_gross_revenue;
	}

	public double getN_gross_revenue() {
		return N_gross_revenue;
	}

	public void setN_gross_revenue(double n_gross_revenue) {
		N_gross_revenue = n_gross_revenue;
	}

	public double getC_gross_revenue() {
		return C_gross_revenue;
	}

	public void setC_gross_revenue(double c_gross_revenue) {
		C_gross_revenue = c_gross_revenue;
	}

	public double getPer_N_amount() {
		return per_N_amount;
	}

	public void setPer_N_amount(double per_N_amount) {
		this.per_N_amount = per_N_amount;
	}

	public double getPer_L_amount() {
		return per_L_amount;
	}

	public void setPer_L_amount(double per_L_amount) {
		this.per_L_amount = per_L_amount;
	}

	public double getL_inventory_cost() {
		return L_inventory_cost;
	}

	public void setL_inventory_cost(double l_inventory_cost) {
		L_inventory_cost = l_inventory_cost;
	}

	public double getN_inventory_cost() {
		return N_inventory_cost;
	}

	public void setN_inventory_cost(double n_inventory_cost) {
		N_inventory_cost = n_inventory_cost;
	}

	public double getC_inventory_cost() {
		return C_inventory_cost;
	}

	public void setC_inventory_cost(double c_inventory_cost) {
		C_inventory_cost = c_inventory_cost;
	}

	public double getPer_C_amount() {
		return per_C_amount;
	}

	public void setPer_C_amount(double per_C_amount) {
		this.per_C_amount = per_C_amount;
	}

}
